﻿using System.Collections.Generic;

namespace HazeCore.Persistence
{
    /// <summary>
    ///  The interface classes that persist types in sequences should implement
    /// </summary>
    /// <typeparam name="T">The type of the items</typeparam>
    public interface ITypeSequencer<T>
    {
        #region Properties

        /// <summary>
        ///  Number of total items in the storage
        /// </summary>
        long Count { get; }

        #endregion

        #region Methods

        /// <summary>
        ///  Keeps the specified items at the specified locatoin
        /// </summary>
        /// <param name="index">The index of the first item</param>
        /// <param name="items">The items to insert</param>
        void InsertRange(long index, IList<T> items);

        /// <summary>
        ///  Removes specified number of consecutive items at specified location
        /// </summary>
        /// <param name="index">The index of the first item to remove</param>
        /// <param name="count">The number of items to remove</param>
        void RemoveRange(long index, long count);

        /// <summary>
        ///  Swaps specified items
        /// </summary>
        /// <param name="index1">The starting index of the first bunch of items to swap</param>
        /// <param name="count1">The number of the first bunch of items to swap</param>
        /// <param name="index2">The starting index of the second bunch of items to swap</param>
        /// <param name="count2">The number of the second bunch of items to swap</param>
        void SwapRange(long index1, long count1, long index2, long count2);

        /// <summary>
        ///  Replaces items at the specified locations with the provided items
        /// </summary>
        /// <param name="index">The starting point of the items to be replaced</param>
        /// <param name="count">The number of items to be replaced</param>
        /// <param name="items">The items to replace the range with</param>
        void ReplaceRange(long index, long count, IList<T> items);

        /// <summary>
        ///  Loads an item from the location in the list 
        /// </summary>
        /// <param name="index">The index at which the item to load from</param>
        /// <returns>The item loaded</returns>
        T Retrieve(long index);

        /// <summary>
        ///  Loads a series of consecutive items from the specified location
        /// </summary>
        /// <param name="index">The index at which the items to load from</param>
        /// <param name="count">The number of items to load</param>
        /// <returns>The items loaded</returns>
        IList<T> RetrieveRange(long index, int count);

        #endregion
    }
}